{% load static %}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>添加菜单</title>
<link rel="stylesheet" href="{% static '/public/css/ui.css' %}">
<link rel="stylesheet" href="{% static '/public/admin/css/layout.css' %}">
<script src="{% static 'public/js/jquery.js' %}"></script>
<script src="{% static 'public/js/ui.js' %}"></script>
</head>

<body class="bg_white">
    <div class="border_iframe">
        <!---->
        <form class="ui-form" method="post">
            <div class="ui-form-group ui-row">
                <label class="ui-col-3 ui-col-form-label">菜单名称：</label>
                <div class="ui-col-9">
                    <input type="text" name="title" class="ui-form-ip" placeholder="请输入菜单名称" data-rule="菜单名称:required;" value="{{title}}">
                </div>
            </div>
            {% if followid != 0 %}
            <div class="ui-form-group ui-row">
                <label class="ui-col-3 ui-col-form-label">控制器名称：</label>
                <div class="ui-col-9">
                    <input type="text" name="cname" class="ui-form-ip" placeholder="请输入控制器名称" data-rule="控制器名称:required;" value="{{cname}}">
                </div>
            </div>
            <div class="ui-form-group ui-row">
                <label class="ui-col-3 ui-col-form-label">动作名称：</label>
                <div class="ui-col-9">
                    <input type="text" name="aname" class="ui-form-ip" placeholder="请输入动作名称" data-rule="动作名称:required;" value="{{aname}}">
                </div>
            </div>
            <div class="ui-form-group ui-row">
                <label class="ui-col-3 ui-col-form-label">附加参数：</label>
                <div class="ui-col-9">
                    <input type="text" name="dname" class="ui-form-ip" value="{{dname}}">
                    <span class="input-tips">格式：a=1&b=2</span>
                </div>
            </div>
            {% endif %}
            <div class="ui-form-group ui-row">
                <label class="ui-col-3 ui-col-form-label">菜单排序：</label>
                <div class="ui-col-9">
                    <input type="text" name="ordnum" class="ui-form-ip" value="{{ordnum}}">
                    <span class="input-tips">数字越小越靠前</span>
                </div>
            </div>
            <div class="ui-form-group ui-row">
                <label class="ui-col-3 ui-col-form-label">状态</label>
                <div class="ui-col-9 col-right-top">
                    <label class="ui-radio"><input type="radio" name="islock" value="1"{% if islock == 1 %} checked{% endif %}><i></i>启用</label>
                    <label class="ui-radio"><input type="radio" name="islock" value="0"{% if islock == 0 %} checked{% endif %}><i></i>锁定</label>
                </div>
            </div>
            <div class="ui-form-group ui-hide">
                <input type="hidden" name="followid" value="{{followid}}">
                {% csrf_token %}
                <button type="submit" id="wmcms-submit">保存</button>
            </div>
        </form>
        <!---->
    </div>
<script>
$(function()
{
	var backurl=window.parent.location;
	$(".ui-form").form(
	{
		type:2,
		align:'bottom-center',
		result:function(form)
		{
			$.ajax(
			{
				type:'post',
				cache:false,
				dataType:'json',
				url:'{% url "manager:menu_edit" id %}',
				data:$(form).serialize(),
				error:function(e){alert(e.responseText);},
				success:function(d)
				{
					if(d.state=='success')
					{
						wmcms.success(d.msg);
						setTimeout(function(){parent.location.href=backurl;},1000);
					}
					else
					{
						wmcms.error(d.msg);
					}  
				}
			});
		}
	});
})
</script>
</body>
</html>